/*
 * @(#)CompoundMetaObject.java	1.0 2000/12/28
 *
 * Copyright 2000 Thomas Barnekow. All Rights Reserved.
 *
 * This software is the proprietary information of Thomas Barnekow.
 * Use is subject to license terms.
 */

package tb.provider;

import java.util.*;

/**
 * This interface is to be implemented by compound, or aggregated, {@link MetaObject}s.
 *
 * @author Thomas Barnekow
 * @version 1.0
 */
public interface CompoundMetaObject extends MetaObject {

  /**
   * Add an <code>element</code>. This is an optional operation.
   *
   * @exception UnsupportedOperationException in case this operation is not supported.
   */
  public boolean add(MetaObject element);

  /**
   * Remove all elements. This is an optional operation.
   *
   * @exception UnsupportedOperationException in case this operation is not supported.
   */
  public void clear();

  /**
   * Does this compound object contain the given <code>element</code>?
   */
  public boolean contains(MetaObject element);

  /**
   * Does this compound meta-object contain zero elements?
   */
  public boolean isEmpty();

  /**
   * Iterate this compound meta-object's elements.
   */
  public Iterator iterator();

  /**
   * Remove the given <code>element</code>. This is an optional operation.
   *
   * @param element the element to be removed
   * @return  <code>true</code>: the <code>element</code> has been removed,
   *          <code>false</code>: otherwise
   * @exception UnsupportedOperationException in case this operation is not supported.
   */
  public boolean remove(MetaObject element);

  /**
   * Get the number of this compound meta-object's elements.
   */
  public int size();

  /**
   * Get the element having the given <code>id</code>.
   *
   * @param id  the element's id
   * @return    the element or <code>null</code>, if there is no such element.
   * @see MetaObject#getId
   */
  public MetaObject get(Comparable id);
}